<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script language="javascript">
function showmabangorder()
{
	$('#showmabangorder').modal('show');	
}
function edit(id)
{
	$.post("/factory/ajaxbutton", {"op": "getaddexpend","id":id},
	  function(data){
		  if(data){
		  	$("#projeck").val(data.projeck);
			$("#type").val(data.type);
			$("#outmoney").val(data.outmoney);
			$("#outtime").val(data.outtime);
			$("#num").val(data.num);
			$("#price").val(data.price);
			$("#descr").val(data.descr);
			$("#editid").val(data.id);
			$("#suppliersearch").val(data.supplier);
			$('#showmabangorder').modal('show');	
		  }
	   },"json");
}
function atmangban()
{
	var projeck = $("#projeck").val();
	if(projeck=="")
	{
		alert("请输入项目名称！");
		return;	
	}
	var type = $("#type").val();
	if(type=="")
	{
		alert("请输入收支类型！");
		return;	
	}
	var outmoney = $("#outmoney").val();
	if(outmoney=="")
	{
		alert("请输入支出金额！");
		return;	
	}
	var outtime = $("#outtime").val();
	var price = $("#price").val();
	var num = $("#num").val();
	var descr = $("#descr").val();
	var editid = $("#editid").val();
	
	var suppliersearch = $("#suppliersearch").val();
	$.post("/factory/ajaxbutton", {"op": "saveaddexpend","projeck":projeck,"type":type,"outmoney":outmoney,"outtime":outtime,"price":price,"num":num,"descr":descr,"suppliersearch":suppliersearch,"editid":editid},
	  function(data){
			if(data==200)
			{
				window.location.href = "/factory/addexpend";	
			}
	   },"text");
}
function ouputcsv()
	{
	
		$("#if_csv").val(1);
		$("#search").attr("target","_thank");
		$("#search").submit();
		
	}
</script>
<title>工厂收支明细列表</title>
<body class="withvernav">
<div class="bodywrapper">
{{include file='/public/leftmenu.tpl'}}
<div class="centercontent">
<div class="pageheader notab">
  <h1 class="pagetitle">工厂支出列表</h1>
  <span class="pagedesc"></span>
  <div class="menulist">
    <ul>
      <ul class="profile_summary">
        <li class="current"> <a href="javascript:void(0)" onClick="showmabangorder()"><span>添加</span></a></li>
      </ul>
    </ul>
  </div>
</div>
<!--pageheader-->
<div id="contentwrapper" class="contentwrapper">
  <div id="basicform" class="subcontent"> 
    <!--搜索栏-->
    <div>
      <div style="clear: both"></div>
      <div class="page">{{$pageList}} 计{{$total}}条记录，共{{$totalpage}}页</div>
    </div>
    <form class="stdform stdform2" method="get" id="search" action="/factory/addexpend">
      <input type='hidden' name='if_csv' id='if_csv'>
      <div class="tableoptions">
        <select name="fID" id="fID"  class="selection " style="width:100px;" >
          <option value="" >工厂</option>
          <option value="12" {{if 12==$fID}} selected{{/if}}>工厂1</option>
          <option value="13" {{if 13==$fID}} selected{{/if}}>工厂2</option>
        </select>
        <select id="st" name="st" class="small_input">
                  <option value="">-请选择收支类型-</option>
                  <option {{if $type=='新品费用'}} selected{{/if}}  value="新品费用">新品费用</option>
                  <option {{if $type=='原材料采购'}} selected{{/if}}  value="原材料采购">原材料采购</option>
                  <option {{if $type=='外包服务'}} selected{{/if}}  value="外包服务">外包服务</option>
                  <option {{if $type=='日常支出'}} selected{{/if}}  value="日常支出">日常支出</option>
                  <option {{if $type=='印花费'}} selected{{/if}}  value="印花费">印花费</option>
                  <option {{if $type=='物流开支'}} selected{{/if}}  value="物流开支">物流开支</option>
                  <option {{if $type=='外出经费'}} selected{{/if}}  value="外出经费">外出经费</option>
                  <option {{if $type=='绣花费'}} selected{{/if}}  value="绣花费">绣花费</option>
                  <option {{if $type=='毛衣加工费'}} selected{{/if}}  value="毛衣加工费">毛衣加工费</option>
                  <option {{if $type=='工人食宿'}} selected{{/if}}  value="工人食宿">工人食宿</option>
                  
                </select>
       
        <select name="ty" id="searchtype" class="selection" style="width:100px;" >
          <option value="1" {{if $ty==1}} selected{{/if}}>支出时间</option>
          <option value="2" {{if $ty==2}} selected{{/if}}>开票时间</option>
        </select>
        <input type="text"  name="starttime" value="{{$starttime}} " onClick="WdatePicker({dateFmt:'yyyy-MM-dd '})" class="width100 hasDatepicker" />
        -
        <input type="text"  name="endtime" value="{{$endtime}} " onClick="WdatePicker({dateFmt:'yyyy-MM-dd '})" class="width100 hasDatepicker" />
        其他:
        <input type="text" name="other" id="other" class="width200" value="{{$other}}" placeholder="" />
        &nbsp;
        <button class="btn btn-primary" id="searchbtn">Search</button>
        {{if $managers || in_array('104',$showpower)}}
        <button onClick="ouputcsv()"  class="stdbtn btn_black">订单导出</button>
        {{/if}} </div>
    </form>
    <!--搜索栏结束-->
    <table cellpadding="0" cellspacing="0" border="0" class="stdtable" style="table-layout: fixed;">
      <thead>
        <tr class="lbbt">
          <td width="6%" bgcolor="#FEFFF1">支出日期</td>
          <td width="6%" bgcolor="#FEFFF1">开票日期</td>
          <td width="6%" bgcolor="#FEFFF1">类型</td>
          <td bgcolor="#FEFFF1" width="10%">项目名称</td>
          <td width="7%" bgcolor="#FEFFF1">价格</td>
          <td width="7%" bgcolor="#FEFFF1">数量</td>
          <td width="7%" bgcolor="#FEFFF1">支出金额</td>
          <td bgcolor="#FEFFF1">描述</td>
          <td  bgcolor="#FEFFF1">供应商</td>
          <td width="6%" bgcolor="#FEFFF1">工号</td>
          <td width="6%" bgcolor="#FEFFF1">部门</td>
          <td  bgcolor="#FEFFF1" width="10%">操作时间</td>
          <td width="6%" bgcolor="#FEFFF1">操作</td>
        </tr>
      </thead>
      <tbody >
       <tr>
        <td valign="middle"  style="position:relative;">&nbsp;</td>
        <td valign="middle" >&nbsp;</td>
        <td   style="position:relative;">&nbsp;</td>
        <td valign="middle" >&nbsp;</td>
        <td valign="middle" >{{$alstprice}}</td>
        <td  class="cz">{{$allnum}}</td>
        <td  class="cz">{{$allprice}}</td>
        <td  class="cz">&nbsp;</td>
        <td  class="cz">&nbsp;</td>
        <td  class="cz">&nbsp;</td>
        <td  class="cz">&nbsp;</td>
        <td  class="cz">&nbsp;</td>
        <td  class="cz">&nbsp;</td>
      </tr>
      {{foreach from=$orderlist item=li key=key}}
     
      <tr>
        <td valign="middle"  style="position:relative;"> {{$li.outtime}} </td>
        <td valign="middle" >{{$li.expenddate}}</td>
        <td   style="position:relative;">{{$li.type}}</td>
        <td valign="middle" >{{$li.projeck}}</td>
        <td valign="middle" >{{$li.price}}</td>
        <td  class="cz">{{$li.num}}</td>
        <td  class="cz">{{$li.outmoney}}</td>
        <td  class="cz"> {{$li.descr}} </td>
        <td  class="cz">{{$li.supplier}}</td>
        <td  class="cz">{{$li.oper}}</td>
        <td  class="cz">{{if $li.factoryid==12}}工厂1{{/if}}{{if $li.factoryid==13}}工厂2{{/if}}</td>
        <td  class="cz">{{$li.opertime}}</td>
        <td  class="cz"><a href="javascript:void(0)" onClick="edit({{$li.id}})">编辑</a> | 
          {{if $managers || $username==$li.oper}}<span><a onClick="return confirm('确认删除？')" href="/factory/ajaxbutton?op=delpexpend&id={{$li.id}}"><img src="/fuman/images/sc.jpg" width="15" height="16" /> 删除</span></a>{{/if}} </td>
      </tr>
      {{/foreach}}
        </tbody>
      
    </table>
    <div class="page">{{$pageList}} 计{{$total}}条记录，共{{$totalpage}}页</div>
  </div>
</div>
<!-- 模态框（Modal）添加支出 -->
<form  method="post">
  <input type="hidden" name="editid" id="editid">
  <div class="modal fade" id="showmabangorder" tabindex="-1" role="dialog" aria-labelledby="sshowmabangorder" aria-hidden="true">
    <div class="modal-dialog" style="width:740px;">
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal" 
               aria-hidden="true">× </button>
          <h4 class="modal-title" id="sshowmabangorder"> 增加收支类型 </h4>
        </div>
        <div class="modal-body">
          <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="100">项目名称： </td>
              <td align="left"><input type="text" name="projeck" id="projeck">
                <font color="#FF0000">(*必选项)</font></td>
            </tr>
            <tr>
              <td width="100">收支类型： </td>
              <td align="left"><select id="type" name="type" class="small_input">
                  <option value="">-请选择收支类型-</option>
                  <option   value="新品费用">新品费用</option>
                  <option   value="原材料采购">原材料采购</option>
                  <option   value="外包服务">外包服务</option>
                  <option   value="日常支出">日常支出</option>
                  <option   value="印花费">印花费</option>
                  <option   value="物流开支">物流开支</option>
                  <option   value="外出经费">外出经费</option>
                  <option   value="绣花费">绣花费</option>
                  <option   value="毛衣加工费">毛衣加工费</option>
                  <option   value="工人食宿">工人食宿</option>
                  
                </select></td>
            </tr>
            <tr>
              <td align="right">支出金额： </td>
              <td align="left"><input type="text" name="outmoney" id="outmoney" value="" maxlength="200" style="width:100px;line-height:0.4;" class="small_input" />
                <font color="#FF0000">(*必填项)</font></td>
            </tr>
            <tr>
              <td  align="right">开票时间： </td>
              <td align="left"><input type="text" name="outtime" id="outtime" value="" maxlength="200" style="width:100px;line-height:0.4;" size=10 class=form  onClick="WdatePicker()" />
                <font color="#FF0000">(*必选项)</font></td>
            </tr>
            <tr>
              <td  align="right">单价： </td>
              <td align="left"><input type="text" name="price" id="price" value="" maxlength="200" style="width:100px;line-height:0.4;" class="small_input" /></td>
            </tr>
            <tr>
              <td align="right">数量： </td>
              <td align="left"><input type="text" name="num" id="num" value="" maxlength="200" style="width:100px;line-height:0.4;" class="small_input" /></td>
            </tr>
            <tr>
              <td  align="right">描述：</td>
              <td  align="left"><textarea  class="full_input" name="descr" id="descr" cols="10" rows="5"></textarea></td>
            </tr>
            <tr >
              <td  align="right">供应商：</td>
              <td  align="left"><input id="suppliersearch" type="text" value="" class="dfinput" style="width: 120pt;height: 20pt;" placeholder="请输入供应商名称"/></td>
            </tr>
          </table>
          <div class="modal-footer">
            <button type="button" class="btn btn-default" 
               data-dismiss="modal"> 关闭 </button>
            <button type="button" class="btn btn-primary"  onclick="atmangban()"> 提交 </button>
          </div>
        </div>
        <!-- /.modal-content --> 
      </div>
      <!-- /.modal-dialog --> 
    </div>
  </div>
  <!-- /.modal -->
</form>
</body>
</html>